<?php
/**
 * 描述
 * Created by Paco
 * Date: 2019/1/25 Time: 11:50
 */

namespace App\Http\Controllers\Admin\Product;


use App\Http\Controllers\Controller;
use App\Http\Request\Product\BrandStore;
use App\Repositories\Product\BrandRepository;
use Illuminate\Http\Request;

class BrandController extends Controller
{
    private $brand;

    public function __construct(BrandRepository $brand)
    {
        $this->brand = $brand;
    }

    public function index()
    {
        return $this->brand->brand();
    }


    public function show($brand_id)
    {
        return $this->brand->show($brand_id);
    }

    /**
     *
     * store
     * author Paco
     * createTime 2019/1/25 14:48
     * @param BrandStore $brand
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @throws \Illuminate\Validation\ValidationException
     */
    public function store(BrandStore $brand, Request $request)
    {
        $params = $brand->validated($request);
        return $this->brand->store($params);
    }


    /**
     *
     * update
     * author Paco
     * createTime 2019/1/25 14:36
     * @param BrandStore $brand
     * @param Request $request
     * @return bool
     * @throws \Illuminate\Validation\ValidationException
     */
    public function update(BrandStore $brand, Request $request)
    {
        $params = $brand->validated($request);
        return $this->brand->save($params);
    }


    public function delete(Request $request)
    {
        $brand_ids = $request->input('brand_ids', 0);
        return $this->brand->del($brand_ids);
    }
}